<template>
  <div class="login-container">
    <h1 class="login-title">应用S23-5班24贾认真-登录框</h1>
    <form @submit.prevent="loginHandle">
      <div class="input-group">
        <label for="username">用户名</label>
        <input type="text" id="username" v-model="username" placeholder="请输入用户名" />
      </div>
      <div class="input-group">
        <label for="password">密码</label>
        <input type="password" id="password" v-model="password" placeholder="请输入密码" />
      </div>
      <button type="submit" class="login-button">登录</button>
    </form>
  </div>
</template>

<script>
export default {
  name: "Mine",
  data() {
    return {
      username: "",
      password: ""
    };
  },
  methods: {
    loginHandle() {
      console.log(111);
      this.$api.login({
        phone: this.username,
        password: this.password
      }).then(res => {
        console.log(res);
      }).catch(err => {
        console.error("登录失败", err);
      });
    }
  }
};
</script>

<style scoped>
.login-container {
  display: flex;
  flex-direction: column;
  /* justify-content: center; */
  align-items: center;
  height: calc(100vh - 50px); /* 调整高度以留出顶部50px的空间 */
  background-color: #f0f0f0;
  padding-top: 50px; /* 添加顶部50px的内边距 */
}

.login-title {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 20px;
  color: #333;
}

form {
  width: 100%;
  max-width: 400px;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  background-color: #fff;
}

.input-group {
  margin-bottom: 15px;
}

label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}

input:focus {
  border-color: #007bff;
  outline: none;
}

.login-button {
  width: 100%;
  padding: 10px;
  background-color: #007bff;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s ease;
}

.login-button:hover {
  background-color: #0056b3;
}

@media (max-width: 400px) {
  form {
    width: 100%;
    padding: 15px;
  }
}
</style>